package com.accesshollywood.grfxOrdering.basics;

import java.util.Date;

import javax.swing.tree.DefaultMutableTreeNode;

import com.accesshollywood.SQL.GFXSQL;
import com.accesshollywood.indexables.GrfxOrder;

public class GrfxOrders {
	
	private GrfxOrderGroup root;
	
	public GrfxOrders(GrfxOrder singleOrder){
		root = new GrfxOrderGroup("ITEMS:");
//		root.add(singleOrder);
	}

	public GrfxOrders(Integer[] orderNumbers) {
		root = new GrfxOrderGroup("ORDERS");
		if (orderNumbers != null) {
			parse(orderNumbers);
		}
	}
	
	public GrfxOrderGroup getRoot() {
		return root;
	}
	
	public void parse(Integer[] orderNumbers){
		for(int i = 0; i < orderNumbers.length; i++){
//			GrfxOrder newOrder = GFXSQL.getOrder(orderNumbers[i]);
//			root.add(newOrder);
		}
	}
	
	
	/**
	 * GrfxOrderGroup represents a group containing other GrfxOrderGroup's as
	 * well as GrfxOrder's. It adds a name and created property to
	 * DefaultMutableTreeNode.
	 */
	
	public static class GrfxOrderGroup extends DefaultMutableTreeNode {
		private Date created;

		public GrfxOrderGroup(String name) {
			super(name);
		}

		public void setName(String name) {
			setUserObject(name);
		}

		public String getName() {
			return (String) getUserObject();
		}

		public void setCreated(Date date) {
			this.created = date;
		}

		public Date getCreated() {
			return created;
		}
	}
	
}
